﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlInputRadioButton : JHtmlInputControl//JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlInputRadioButton htmlInputRadioButton;

        public JHtmlInputRadioButton(System.Web.UI.HtmlControls.HtmlInputRadioButton htmlInputRadioButton)
            : base(htmlInputRadioButton)
        {
            this.htmlInputRadioButton = htmlInputRadioButton;
        }


        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "checked":
                case "check":
                    Value = htmlInputRadioButton.Checked;
                    return;
                default:
                    base.Attr(key); return;
            }
        }

        public override void Attr(string key, string value)
        {
            bool f;
            bool.TryParse(value, out f);
            switch (key.ToLower())
            {
                case "checked":
                case "check":
                    htmlInputRadioButton.Checked = f;
                    return;
                default:
                    base.Attr(key, value); return;
            }
        }
    }
}
